Option Strict On
Option Explicit On 

Public Class UGrouper
    Inherits System.Windows.Forms.UserControl

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    Friend WithEvents chkRepeatOnEveryPage As System.Windows.Forms.CheckBox
    Friend WithEvents cboNewPage As System.Windows.Forms.ComboBox
    Friend WithEvents lblNewPage As System.Windows.Forms.Label
    Friend WithEvents chkKeepTogether As System.Windows.Forms.CheckBox
    Friend WithEvents chkPrintBackGround As System.Windows.Forms.CheckBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(UGrouper))
        Me.chkRepeatOnEveryPage = New System.Windows.Forms.CheckBox
        Me.cboNewPage = New System.Windows.Forms.ComboBox
        Me.lblNewPage = New System.Windows.Forms.Label
        Me.chkKeepTogether = New System.Windows.Forms.CheckBox
        Me.chkPrintBackGround = New System.Windows.Forms.CheckBox
        Me.SuspendLayout()
        '
        'chkRepeatOnEveryPage
        '
        Me.chkRepeatOnEveryPage.AccessibleDescription = resources.GetString("chkRepeatOnEveryPage.AccessibleDescription")
        Me.chkRepeatOnEveryPage.AccessibleName = resources.GetString("chkRepeatOnEveryPage.AccessibleName")
        Me.chkRepeatOnEveryPage.Anchor = CType(resources.GetObject("chkRepeatOnEveryPage.Anchor"), System.Windows.Forms.AnchorStyles)
        Me.chkRepeatOnEveryPage.Appearance = CType(resources.GetObject("chkRepeatOnEveryPage.Appearance"), System.Windows.Forms.Appearance)
        Me.chkRepeatOnEveryPage.BackgroundImage = CType(resources.GetObject("chkRepeatOnEveryPage.BackgroundImage"), System.Drawing.Image)
        Me.chkRepeatOnEveryPage.CheckAlign = CType(resources.GetObject("chkRepeatOnEveryPage.CheckAlign"), System.Drawing.ContentAlignment)
        Me.chkRepeatOnEveryPage.Dock = CType(resources.GetObject("chkRepeatOnEveryPage.Dock"), System.Windows.Forms.DockStyle)
        Me.chkRepeatOnEveryPage.Enabled = CType(resources.GetObject("chkRepeatOnEveryPage.Enabled"), Boolean)
        Me.chkRepeatOnEveryPage.FlatStyle = CType(resources.GetObject("chkRepeatOnEveryPage.FlatStyle"), System.Windows.Forms.FlatStyle)
        Me.chkRepeatOnEveryPage.Font = CType(resources.GetObject("chkRepeatOnEveryPage.Font"), System.Drawing.Font)
        Me.chkRepeatOnEveryPage.Image = CType(resources.GetObject("chkRepeatOnEveryPage.Image"), System.Drawing.Image)
        Me.chkRepeatOnEveryPage.ImageAlign = CType(resources.GetObject("chkRepeatOnEveryPage.ImageAlign"), System.Drawing.ContentAlignment)
        Me.chkRepeatOnEveryPage.ImageIndex = CType(resources.GetObject("chkRepeatOnEveryPage.ImageIndex"), Integer)
        Me.chkRepeatOnEveryPage.ImeMode = CType(resources.GetObject("chkRepeatOnEveryPage.ImeMode"), System.Windows.Forms.ImeMode)
        Me.chkRepeatOnEveryPage.Location = CType(resources.GetObject("chkRepeatOnEveryPage.Location"), System.Drawing.Point)
        Me.chkRepeatOnEveryPage.Name = "chkRepeatOnEveryPage"
        Me.chkRepeatOnEveryPage.RightToLeft = CType(resources.GetObject("chkRepeatOnEveryPage.RightToLeft"), System.Windows.Forms.RightToLeft)
        Me.chkRepeatOnEveryPage.Size = CType(resources.GetObject("chkRepeatOnEveryPage.Size"), System.Drawing.Size)
        Me.chkRepeatOnEveryPage.TabIndex = CType(resources.GetObject("chkRepeatOnEveryPage.TabIndex"), Integer)
        Me.chkRepeatOnEveryPage.Text = resources.GetString("chkRepeatOnEveryPage.Text")
        Me.chkRepeatOnEveryPage.TextAlign = CType(resources.GetObject("chkRepeatOnEveryPage.TextAlign"), System.Drawing.ContentAlignment)
        Me.chkRepeatOnEveryPage.Visible = CType(resources.GetObject("chkRepeatOnEveryPage.Visible"), Boolean)
        '
        'cboNewPage
        '
        Me.cboNewPage.AccessibleDescription = resources.GetString("cboNewPage.AccessibleDescription")
        Me.cboNewPage.AccessibleName = resources.GetString("cboNewPage.AccessibleName")
        Me.cboNewPage.Anchor = CType(resources.GetObject("cboNewPage.Anchor"), System.Windows.Forms.AnchorStyles)
        Me.cboNewPage.BackColor = System.Drawing.SystemColors.Window
        Me.cboNewPage.BackgroundImage = CType(resources.GetObject("cboNewPage.BackgroundImage"), System.Drawing.Image)
        Me.cboNewPage.Dock = CType(resources.GetObject("cboNewPage.Dock"), System.Windows.Forms.DockStyle)
        Me.cboNewPage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
        Me.cboNewPage.Enabled = CType(resources.GetObject("cboNewPage.Enabled"), Boolean)
        Me.cboNewPage.Font = CType(resources.GetObject("cboNewPage.Font"), System.Drawing.Font)
        Me.cboNewPage.ImeMode = CType(resources.GetObject("cboNewPage.ImeMode"), System.Windows.Forms.ImeMode)
        Me.cboNewPage.IntegralHeight = CType(resources.GetObject("cboNewPage.IntegralHeight"), Boolean)
        Me.cboNewPage.ItemHeight = CType(resources.GetObject("cboNewPage.ItemHeight"), Integer)
        Me.cboNewPage.Location = CType(resources.GetObject("cboNewPage.Location"), System.Drawing.Point)
        Me.cboNewPage.MaxDropDownItems = CType(resources.GetObject("cboNewPage.MaxDropDownItems"), Integer)
        Me.cboNewPage.MaxLength = CType(resources.GetObject("cboNewPage.MaxLength"), Integer)
        Me.cboNewPage.Name = "cboNewPage"
        Me.cboNewPage.RightToLeft = CType(resources.GetObject("cboNewPage.RightToLeft"), System.Windows.Forms.RightToLeft)
        Me.cboNewPage.Size = CType(resources.GetObject("cboNewPage.Size"), System.Drawing.Size)
        Me.cboNewPage.TabIndex = CType(resources.GetObject("cboNewPage.TabIndex"), Integer)
        Me.cboNewPage.Text = resources.GetString("cboNewPage.Text")
        Me.cboNewPage.Visible = CType(resources.GetObject("cboNewPage.Visible"), Boolean)
        '
        'lblNewPage
        '
        Me.lblNewPage.AccessibleDescription = resources.GetString("lblNewPage.AccessibleDescription")
        Me.lblNewPage.AccessibleName = resources.GetString("lblNewPage.AccessibleName")
        Me.lblNewPage.Anchor = CType(resources.GetObject("lblNewPage.Anchor"), System.Windows.Forms.AnchorStyles)
        Me.lblNewPage.AutoSize = CType(resources.GetObject("lblNewPage.AutoSize"), Boolean)
        Me.lblNewPage.Dock = CType(resources.GetObject("lblNewPage.Dock"), System.Windows.Forms.DockStyle)
        Me.lblNewPage.Enabled = CType(resources.GetObject("lblNewPage.Enabled"), Boolean)
        Me.lblNewPage.Font = CType(resources.GetObject("lblNewPage.Font"), System.Drawing.Font)
        Me.lblNewPage.Image = CType(resources.GetObject("lblNewPage.Image"), System.Drawing.Image)
        Me.lblNewPage.ImageAlign = CType(resources.GetObject("lblNewPage.ImageAlign"), System.Drawing.ContentAlignment)
        Me.lblNewPage.ImageIndex = CType(resources.GetObject("lblNewPage.ImageIndex"), Integer)
        Me.lblNewPage.ImeMode = CType(resources.GetObject("lblNewPage.ImeMode"), System.Windows.Forms.ImeMode)
        Me.lblNewPage.Location = CType(resources.GetObject("lblNewPage.Location"), System.Drawing.Point)
        Me.lblNewPage.Name = "lblNewPage"
        Me.lblNewPage.RightToLeft = CType(resources.GetObject("lblNewPage.RightToLeft"), System.Windows.Forms.RightToLeft)
        Me.lblNewPage.Size = CType(resources.GetObject("lblNewPage.Size"), System.Drawing.Size)
        Me.lblNewPage.TabIndex = CType(resources.GetObject("lblNewPage.TabIndex"), Integer)
        Me.lblNewPage.Text = resources.GetString("lblNewPage.Text")
        Me.lblNewPage.TextAlign = CType(resources.GetObject("lblNewPage.TextAlign"), System.Drawing.ContentAlignment)
        Me.lblNewPage.Visible = CType(resources.GetObject("lblNewPage.Visible"), Boolean)
        '
        'chkKeepTogether
        '
        Me.chkKeepTogether.AccessibleDescription = resources.GetString("chkKeepTogether.AccessibleDescription")
        Me.chkKeepTogether.AccessibleName = resources.GetString("chkKeepTogether.AccessibleName")
        Me.chkKeepTogether.Anchor = CType(resources.GetObject("chkKeepTogether.Anchor"), System.Windows.Forms.AnchorStyles)
        Me.chkKeepTogether.Appearance = CType(resources.GetObject("chkKeepTogether.Appearance"), System.Windows.Forms.Appearance)
        Me.chkKeepTogether.BackgroundImage = CType(resources.GetObject("chkKeepTogether.BackgroundImage"), System.Drawing.Image)
        Me.chkKeepTogether.CheckAlign = CType(resources.GetObject("chkKeepTogether.CheckAlign"), System.Drawing.ContentAlignment)
        Me.chkKeepTogether.Dock = CType(resources.GetObject("chkKeepTogether.Dock"), System.Windows.Forms.DockStyle)
        Me.chkKeepTogether.Enabled = CType(resources.GetObject("chkKeepTogether.Enabled"), Boolean)
        Me.chkKeepTogether.FlatStyle = CType(resources.GetObject("chkKeepTogether.FlatStyle"), System.Windows.Forms.FlatStyle)
        Me.chkKeepTogether.Font = CType(resources.GetObject("chkKeepTogether.Font"), System.Drawing.Font)
        Me.chkKeepTogether.Image = CType(resources.GetObject("chkKeepTogether.Image"), System.Drawing.Image)
        Me.chkKeepTogether.ImageAlign = CType(resources.GetObject("chkKeepTogether.ImageAlign"), System.Drawing.ContentAlignment)
        Me.chkKeepTogether.ImageIndex = CType(resources.GetObject("chkKeepTogether.ImageIndex"), Integer)
        Me.chkKeepTogether.ImeMode = CType(resources.GetObject("chkKeepTogether.ImeMode"), System.Windows.Forms.ImeMode)
        Me.chkKeepTogether.Location = CType(resources.GetObject("chkKeepTogether.Location"), System.Drawing.Point)
        Me.chkKeepTogether.Name = "chkKeepTogether"
        Me.chkKeepTogether.RightToLeft = CType(resources.GetObject("chkKeepTogether.RightToLeft"), System.Windows.Forms.RightToLeft)
        Me.chkKeepTogether.Size = CType(resources.GetObject("chkKeepTogether.Size"), System.Drawing.Size)
        Me.chkKeepTogether.TabIndex = CType(resources.GetObject("chkKeepTogether.TabIndex"), Integer)
        Me.chkKeepTogether.Text = resources.GetString("chkKeepTogether.Text")
        Me.chkKeepTogether.TextAlign = CType(resources.GetObject("chkKeepTogether.TextAlign"), System.Drawing.ContentAlignment)
        Me.chkKeepTogether.Visible = CType(resources.GetObject("chkKeepTogether.Visible"), Boolean)
        '
        'chkPrintBackGround
        '
        Me.chkPrintBackGround.AccessibleDescription = resources.GetString("chkPrintBackGround.AccessibleDescription")
        Me.chkPrintBackGround.AccessibleName = resources.GetString("chkPrintBackGround.AccessibleName")
        Me.chkPrintBackGround.Anchor = CType(resources.GetObject("chkPrintBackGround.Anchor"), System.Windows.Forms.AnchorStyles)
        Me.chkPrintBackGround.Appearance = CType(resources.GetObject("chkPrintBackGround.Appearance"), System.Windows.Forms.Appearance)
        Me.chkPrintBackGround.BackgroundImage = CType(resources.GetObject("chkPrintBackGround.BackgroundImage"), System.Drawing.Image)
        Me.chkPrintBackGround.CheckAlign = CType(resources.GetObject("chkPrintBackGround.CheckAlign"), System.Drawing.ContentAlignment)
        Me.chkPrintBackGround.Dock = CType(resources.GetObject("chkPrintBackGround.Dock"), System.Windows.Forms.DockStyle)
        Me.chkPrintBackGround.Enabled = CType(resources.GetObject("chkPrintBackGround.Enabled"), Boolean)
        Me.chkPrintBackGround.FlatStyle = CType(resources.GetObject("chkPrintBackGround.FlatStyle"), System.Windows.Forms.FlatStyle)
        Me.chkPrintBackGround.Font = CType(resources.GetObject("chkPrintBackGround.Font"), System.Drawing.Font)
        Me.chkPrintBackGround.Image = CType(resources.GetObject("chkPrintBackGround.Image"), System.Drawing.Image)
        Me.chkPrintBackGround.ImageAlign = CType(resources.GetObject("chkPrintBackGround.ImageAlign"), System.Drawing.ContentAlignment)
        Me.chkPrintBackGround.ImageIndex = CType(resources.GetObject("chkPrintBackGround.ImageIndex"), Integer)
        Me.chkPrintBackGround.ImeMode = CType(resources.GetObject("chkPrintBackGround.ImeMode"), System.Windows.Forms.ImeMode)
        Me.chkPrintBackGround.Location = CType(resources.GetObject("chkPrintBackGround.Location"), System.Drawing.Point)
        Me.chkPrintBackGround.Name = "chkPrintBackGround"
        Me.chkPrintBackGround.RightToLeft = CType(resources.GetObject("chkPrintBackGround.RightToLeft"), System.Windows.Forms.RightToLeft)
        Me.chkPrintBackGround.Size = CType(resources.GetObject("chkPrintBackGround.Size"), System.Drawing.Size)
        Me.chkPrintBackGround.TabIndex = CType(resources.GetObject("chkPrintBackGround.TabIndex"), Integer)
        Me.chkPrintBackGround.Text = resources.GetString("chkPrintBackGround.Text")
        Me.chkPrintBackGround.TextAlign = CType(resources.GetObject("chkPrintBackGround.TextAlign"), System.Drawing.ContentAlignment)
        Me.chkPrintBackGround.Visible = CType(resources.GetObject("chkPrintBackGround.Visible"), Boolean)
        '
        'UGrouper
        '
        Me.AccessibleDescription = resources.GetString("$this.AccessibleDescription")
        Me.AccessibleName = resources.GetString("$this.AccessibleName")
        Me.AutoScroll = CType(resources.GetObject("$this.AutoScroll"), Boolean)
        Me.AutoScrollMargin = CType(resources.GetObject("$this.AutoScrollMargin"), System.Drawing.Size)
        Me.AutoScrollMinSize = CType(resources.GetObject("$this.AutoScrollMinSize"), System.Drawing.Size)
        Me.BackgroundImage = CType(resources.GetObject("$this.BackgroundImage"), System.Drawing.Image)
        Me.Controls.Add(Me.chkPrintBackGround)
        Me.Controls.Add(Me.chkKeepTogether)
        Me.Controls.Add(Me.cboNewPage)
        Me.Controls.Add(Me.lblNewPage)
        Me.Controls.Add(Me.chkRepeatOnEveryPage)
        Me.Enabled = CType(resources.GetObject("$this.Enabled"), Boolean)
        Me.Font = CType(resources.GetObject("$this.Font"), System.Drawing.Font)
        Me.ImeMode = CType(resources.GetObject("$this.ImeMode"), System.Windows.Forms.ImeMode)
        Me.Location = CType(resources.GetObject("$this.Location"), System.Drawing.Point)
        Me.Name = "UGrouper"
        Me.RightToLeft = CType(resources.GetObject("$this.RightToLeft"), System.Windows.Forms.RightToLeft)
        Me.Size = CType(resources.GetObject("$this.Size"), System.Drawing.Size)
        Me.ResumeLayout(False)

    End Sub

#End Region

    Public Event ValueChanged As EventHandler

    Private Sub Ugroup_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        AddHandler cboNewPage.SelectionChangeCommitted, AddressOf OnValueChanged
        AddHandler chkKeepTogether.CheckedChanged, AddressOf OnValueChanged
        AddHandler chkRepeatOnEveryPage.CheckedChanged, AddressOf OnValueChanged
        AddHandler chkPrintBackGround.CheckedChanged, AddressOf OnValueChanged
    End Sub

    Protected Sub OnValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs)
        RaiseEvent ValueChanged(Me, New EventArgs)
    End Sub

    Public Sub Prepare()
        cboNewPage.Items.Clear()

        cboNewPage.Items.Clear()
        cboNewPage.Items.Add(Model10.NewPageMode.None)
        cboNewPage.Items.Add(Model10.NewPageMode.Before)
        cboNewPage.Items.Add(Model10.NewPageMode.After)
        cboNewPage.Items.Add(Model10.NewPageMode.BeforeAndAfter)
    End Sub

    Public Sub Read(ByVal grouper As Model10.Grouper)
        cboNewPage.SelectedItem = grouper.NewPage
        chkKeepTogether.Checked = grouper.KeepTogether
        chkRepeatOnEveryPage.Checked = grouper.RepeatOnEveryPage
        chkPrintBackGround.Checked = grouper.PrintBackground
    End Sub
    Public Sub Write(ByVal grouper As Model10.Grouper)
        grouper.NewPage = CType(cboNewPage.SelectedItem, Model10.NewPageMode)
        grouper.KeepTogether = chkKeepTogether.Checked
        grouper.RepeatOnEveryPage = chkRepeatOnEveryPage.Checked
        grouper.PrintBackground = chkPrintBackGround.Checked
    End Sub
End Class